//
//  MyTableViewCell.m
//  MyWeChat
//
//  Created by 蔡欣东 on 15/10/5.
//  Copyright © 2015年 蔡欣东. All rights reserved.
//

#import "MyTableViewCell.h"
#import "UIColor+UIColor_random.h"
@implementation MyTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifie{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifie]) {
        self.cellBackgroundView = [[UIView alloc]initWithFrame: CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 55)];
        self.cellBackgroundView.backgroundColor = [UIColor clearColor];
        self.avatar = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 45, 45)];
        self.avatar.image = [UIImage imageNamed:@"touxiang"];
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(55, 0, [UIScreen mainScreen].bounds.size.width-55, 55)];
        self.nameLabel.text = @"123";
        self.nameLabel.font = [UIFont fontWithName:@"ChalkboardSE-Regular" size:18];
    
        [self.cellBackgroundView addSubview:self.avatar];
        [self.cellBackgroundView addSubview:self.nameLabel];
        [self addSubview:self.cellBackgroundView];
        
        self.backgroundColor = [UIColor clearColor];
        
        self.cellBackgroundView.layer.shadowColor = [UIColor clearColor].CGColor;
        self.cellBackgroundView.layer.shadowOffset = CGSizeMake(0, 2);
        self.cellBackgroundView.layer.shadowOpacity = 0.8;
        self.cellBackgroundView.layer.shadowPath = CGPathCreateWithRect(self.bounds, nil);
        
        self.tipView = [[UIImageView alloc]init];
        self.tipView.frame = CGRectMake(40,-4, 20, 20);
        self.tipView.image = [UIImage imageNamed:@"a3o"];
        self.tipView.hidden = YES;
        [self addSubview:self.tipView];
    }
    return self;

    
    
}
+(NSString *)reuseIdentifier{
    return @"friendCell";
}
+(CGFloat)heightForCell{
    return 56;
}
-(void)setupCell:(UserInfo *)user{
    if ([user.name isEqual:@""]) {
        self.nameLabel.text = @"Someone";
    }else{
        self.nameLabel.text = [user.name componentsSeparatedByString:@"@"][0] ;
    }
    self.cellBackgroundView.backgroundColor = [UIColor randomColor];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
